<?php
	require_once('../includes/config.php');
	require_once('../includes/functions.php');
	
	// Retrieve base HTML
	$pageStr = buildStandardPage('Welcome', 'Signed In');
	$content = '';

	if(isMobile()){
		$content .= 'Detected Mobile!';
	}
	else{
		/**
		 * We need to check that the user is logged in because this page is still accessible
		 * without logging in.
		 */
		if(true == isLoggedIn()){
			$userInfo = getLoggedInUser();
			$pageStr = buildStandardPage('Welcome, ' . $userInfo['firstname'], 'Signed In');
			
			// Say Hello to the user! :)
//			$content .= 'Hello, '. $userInfo['firstname'] . ' ' . $userInfo['lastname'];
			
			if(true == isCustomer()){
				if(true == isActive()){
					$content .= '<a href='. $USERS_URL . 'edit.php >Edit Profile</a>';
					$content .= '<br/><br/>Here is your account at a glance:<br/>';
					$content .= buildAccountTable($_SESSION['id']);
				}
				else{
					$content .= $NOT_ACTIVE_MESSAGE;
				}
			}
			else { // It's a bank manager or system admin
				$content .= '<br/><br/>Here is the list of users at glance:<br/>';
				$content .= buildUserTable();
			}
		}
		else{
			$content .= $FAILED_TO_LOG_IN;
		}
	}

	/**
	 * Replace the content string
	 */
	$pageStr = str_Replace('<!--content-->', $content, $pageStr);

	/**
	 * Send the generated HTML to the client's browser
	 */
	echo $pageStr;
?>